package cn.tedu.yl.doctors.controller;

import cn.tedu.yl.base.response.JsonResult;
import cn.tedu.yl.base.response.PageData;
import cn.tedu.yl.department.pojo.Department;
import cn.tedu.yl.department.service.DepartmentService;
import cn.tedu.yl.doctors.pojo.Doctors;
import cn.tedu.yl.doctors.service.DoctrosService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "医生模块")
@RestController
@RequestMapping("/v1/doctros")
@Slf4j
public class DoctrosController {
    @Autowired
    private DoctrosService departmentService;

    @GetMapping("select")
    public JsonResult getAllArticles() {
        PageData list =departmentService.getAllDepartment();
        return JsonResult.ok(list);
    }

//    @GetMapping("select/{id}")
//    public Department getArticleById(@PathVariable Long id) {
//        return departmentService.getDepartmentById(id);
//    }

    @PostMapping("create")
    public JsonResult createArticle(@RequestBody Doctors article) {
         departmentService.createArticle(article);
         return JsonResult.ok();
    }

    @PutMapping("update/{id}")
    public JsonResult updateArticle(@PathVariable(value = "id") Long id, @RequestBody Doctors articleDetails) {
        log.info("articleDetails:{},id:{}",articleDetails,id);
        departmentService.updateArticle(id, articleDetails);
        return JsonResult.ok();
    }

    @DeleteMapping("delete/{id}")
    public JsonResult deleteArticle(@PathVariable(value = "id") Long id) {
        departmentService.deleteDepartment(id);
        return JsonResult.ok();
    }
}
